package com.ruoyi.project.mahjong.controller;

import java.util.List;

import com.ruoyi.project.mahjong.domain.vo.MemberEventVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mahjong.domain.TMemberLog;
import com.ruoyi.project.mahjong.service.ITMemberLogService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户操作记录Controller
 *
 * @author ruoyi
 * @date 2023-11-12
 */
@RestController
@RequestMapping("/mahjong/log")
public class TMemberLogController extends BaseController
{
    @Autowired
    private ITMemberLogService tMemberLogService;

    /**
     * 查询用户操作记录列表
     */
//    @PreAuthorize("@ss.hasPermi('mahjong:log:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(TMemberLog tMemberLog)
//    {
//        startPage();
//        List<TMemberLog> list = tMemberLogService.selectTMemberLogList(tMemberLog);
//        return getDataTable(list);
//    }

    @PreAuthorize("@ss.hasPermi('mahjong:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMemberLog tMemberLog)
    {
        startPage();
        List<MemberEventVo> list = tMemberLogService.selectMemberEvent(tMemberLog);
        return getDataTable(list);
    }
    /**
     * 导出用户操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:log:export')")
    @Log(title = "用户操作记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TMemberLog tMemberLog)
    {
        List<TMemberLog> list = tMemberLogService.selectTMemberLogList(tMemberLog);
        ExcelUtil<TMemberLog> util = new ExcelUtil<TMemberLog>(TMemberLog.class);
        return util.exportExcel(list, "log");
    }

    /**
     * 获取用户操作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('mahjong:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tMemberLogService.selectTMemberLogById(id));
    }

    /**
     * 新增用户操作记录
     */
    @PreAuthorize("@ss.hasPermi('mahjong:log:add')")
    @Log(title = "用户操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMemberLog tMemberLog)
    {
        return toAjax(tMemberLogService.insertTMemberLog(tMemberLog));
    }

    /**
     * 修改用户操作记录
     */
    @PreAuthorize("@ss.hasPermi('mahjong:log:edit')")
    @Log(title = "用户操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMemberLog tMemberLog)
    {
        return toAjax(tMemberLogService.updateTMemberLog(tMemberLog));
    }

    /**
     * 删除用户操作记录
     */
    @PreAuthorize("@ss.hasPermi('mahjong:log:remove')")
    @Log(title = "用户操作记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tMemberLogService.deleteTMemberLogByIds(ids));
    }
}
